package com.mz.ozy.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mz.ozy.R;
import com.mz.ozy.WpkApp;


/**
 * Created by Administrator on 2018/1/5.
 */

public class PayDialog extends Dialog {
    private ImageView iv_close;
    private PayEditText pwd;
    //    private TextView settingPwd;
    private Context context;

    public PayDialog(@NonNull Context context) {
        super(context, R.style.custom_dialog);
        this.context = context;
    }

    public PayDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected PayDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pay_dialog);
        initStyle();
        iv_close = findViewById(R.id.iv_close);
//        settingPwd = findViewById(R.id.settingPwd);
        pwd = findViewById(R.id.pwd);
        pwd.initStyle(R.drawable.pay_pwd_round, 6, 0.33f, R.color.line, R.color.text_color_333333, 18);

        iv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
//        settingPwd.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
////                ModifyPwdActivity.go(context,1);
//            }
//        });

        pwd.postDelayed(new Runnable() {
            @Override
            public void run() {
                pwd.setFocus();
            }
        }, 100);
    }

    private void initStyle() {
        Window dialogWindow = getWindow();
        WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
        p.width = (int) (WpkApp.screenWidth * 0.8); // 宽度设置为屏幕的0.65，根据实际情况调整
        dialogWindow.setAttributes(p);
    }

    public PayEditText getPwd() {
        return pwd;
    }

    public void setPwd(PayEditText pwd) {
        this.pwd = pwd;
    }

}
